<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>首页职位</title>
      <link rel="stylesheet" type="text/css" href="../css/api.css"/>
      <link rel="stylesheet" type="text/css" href="../css/style.css"/>
      <style>
      .content{width: 100%}
      .list{padding: 50px 15px 20px;}
      .list .wrap{display: flex;flex-direction: column;justify-content: space-around;padding-bottom: 28px}
      .list .wrap .item{display: flex;align-items: center;justify-content: space-between;}
      .list .wrap .item .title{font-size: 16px;color: #000;font-weight: 600;overflow: hidden;
text-overflow: ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;}
      .list .wrap .item .money{ color: #EB5758;flex-shrink:0}
      .list .wrap .item .money .redfont{font-size: 24px}
      .list .wrap .item.self{justify-content: flex-start;margin-bottom: 5px}
      .list .wrap .item.self span{padding: 3px 9px;color:  #8B8EA3;font-size: 11px;border-radius: 5px;background-color:  #E4E7F0;display: inline-block;}
      .list .wrap .item.self span.sex{margin-right: 10px}
      .list .wrap .item .target{color: #999}
      .list .wrap .item .type{color: #999}
      </style>
  </head>
  <body>
    <div class="content">
      <div class="returnBox">
        <div class="return"> <img src="../image/return.png" onclick="api.closeWin()"> <span class="us">最新职位</span></div>
      </div>
      <div class="list" id="weeked">

      </div>
    </div>
  </body>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/encrypt.js"></script>
  <script type="text/javascript">
      apiready = function(){
        $api.fixStatusBar($api.dom('.content'));
        var base = new Base64();
        var tagCode = api.pageParam.tagCode

        switch (tagCode) {
          case 'SYGX':
            $api.html($api.dom('.us'), '高薪职位');
            break;
          case 'SYDR':
            $api.html($api.dom('.us'), '当日结算');
            break;
          case 'SYJS':
            $api.html($api.dom('.us'), '极速上岗');
            break;
          case 'SYZJ':
            $api.html($api.dom('.us'), '在家可做');
            break;


        }
        refersh()
        init(1)
        var b = 0;
        var pi = 1
        var arryHtml = [];
        function init(pi){
          var pz = 20
          var json = {'tagCode':tagCode,'pi':pi,'pz':pz}
          var parameter = base.encode(JSON.stringify(json));
          var signValue = parameter + secretKey
          var sign = signValue.MD5(32)
          $api.post(url+'getJobListByCode.ashx', {values:{parameter:parameter,sign:sign}}, function(ret){
            if(ret.code == 200){

              var html = '';
              var data = ret.data.JobList;

              b = data.length
              if(!data.length){
                b = 0
              }
              if (b > 0) {
                arryHtml = arryHtml.concat(data)
                for (var i = 0,iL=arryHtml.length; i < iL; i++) {
                  html+='<div class="wrap" data-id="'+arryHtml[i].jianZhiID+'">'+
                  '<div class="item">'+
                  '<div class="title">'+arryHtml[i].listTitle+'</div>'+
                  '<div class="money"><span class="redfont">'+arryHtml[i].salary+'</span>'

                  if(arryHtml[i].salaryUnit == 10){ //薪水单位
                    html+='元/小时</div>'
                  }else if(arryHtml[i].salaryUnit == 20){
                    html+='元/次</div>'
                  }else if(arryHtml[i].salaryUnit == 30){
                    html+='元/天</div>'
                  }

                  html+='</div>'+
                  '<div class="item self">'

                  if(arryHtml[i].sex == 10){ //性别要求
                    html+='<span class="sex">仅限男</span>'
                  }else if(arryHtml[i].sex == 20){
                    html+='<span class="sex">仅限女</span>'

                  }else if(arryHtml[i].sex == 30){
                    html+='<span class="sex">男女不限</span>'
                  }

                  if(arryHtml[i].effective == 10){ //有效时间
                    html+='<span>长期</span>'
                  }

                  html+='</div>'+
                  '<div class="item">'+
                  '<div class="target">'+arryHtml[i].detailContent+'</div>'

                  if(arryHtml[i].paymentTerms == 10){ //结算方式
                    html+='<div class="type">日结</div>'
                  }else if(arryHtml[i].paymentTerms == 20){
                    html+='<div class="type">周结</div>'
                  }else if(arryHtml[i].paymentTerms == 30){
                    html+='<div class="type">月结</div>'
                  }
                  html+='</div>'+
                  '</div>'

                }
              }

              $api.html($api.dom('#weeked'), html);

              var wrapList = $api.domAll('.wrap');
              for (var i = 0; i < wrapList.length; i++) {
                $api.addEvt(wrapList[i], 'click', function(){
                  var jianZhiID = $api.attr(this,'data-id')
                  api.openWin({
                    name: 'jobDetails',
                    url: './jobDetails.html',
                    pageParam:{
                      jianZhiID:jianZhiID
                    }
                  });

                });
              }

            }else{
              api.toast({
                msg: ret.msg,
                duration: 2000,
                location: 'middle'
              });
            }
          })

        }
        api.addEventListener({
            name:'scrolltobottom',
            extra:{
                threshold:20           //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function(ret, err){

          if (b <20 ) {
                $api.append($api.dom('#weeked'),'<div class="nomore">没有更多了~</div>')
                api.removeEventListener({
                    name: 'scrolltobottom'
                });
            } else {
                pi+=1;
                init(pi)
            }
        });
      };
  </script>
  </html>
